import { inject, InjectionKey, reactive } from 'vue'
import { v4 } from 'uuid'

export interface FlowState {
  currentCell: any
  flow: any
}

export const createFlowState = () => {
  const state: FlowState = reactive({
    currentCell: null,
    flow: {
      id: v4()
    }
  })

  return state
}

export const flowStateKey: InjectionKey<FlowState> = Symbol('FlowState')

export const useFlowState = () => {
  const state = inject(flowStateKey)!
  return {
    state
  }
}
